home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 2002
- // Author: dbrins
- //
- // Description:
- // Option box for paint effects to poly
- //
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- // Note:
- // Commented out Type option for this rev
- //
- proc setOptionVars(int $forceFactorySettings)
- {
-
- // Vertex Color Mode
- //
- if ($forceFactorySettings ||
- !`optionVar -exists pfxToPolyVertColorMode`) {
- optionVar -intValue pfxToPolyVertColorMode 0;
- }
-
-
- // Quad Output
- //
- if ($forceFactorySettings ||
- !`optionVar -exists pfxToPolyQuadOutput`) {
- optionVar -intValue pfxToPolyQuadOutput 0;
- }
-
- // HideStrokes
- //
- if ($forceFactorySettings ||
- !`optionVar -exists pfxToPolyHideStrokes`) {
- optionVar -intValue pfxToPolyHideStrokes 1;
- }
-
- // Poly Limit
- //
- if ($forceFactorySettings ||
- !`optionVar -exists pfxToPolyLimit`) {
- optionVar -intValue pfxToPolyLimit 100000;
- }
-
- }
-
-
- //
- // Procedure Name:
- // paintEffectsToPolySetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc paintEffectsToPolySetup(string $parent, int $forceFactorySettings)
- {
- int $method;
-
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Vertex Color Mode
- int $mode = `optionVar -query pfxToPolyVertColorMode`;
- radioButtonGrp -edit -select ($mode+1) pfxToPolyVertColorMode;
-
- // Quad Output
- //
- int $quadOutput = `optionVar -query pfxToPolyQuadOutput`;
- checkBoxGrp -edit -v1 $quadOutput pfxToPolyQuadOutputBox;
-
- // Hide Strokes
- //
- int $hideStrokes = `optionVar -query pfxToPolyHideStrokes`;
- checkBoxGrp -edit -v1 $hideStrokes pfxToPolyHideStrokesBox;
-
- // Poly Limit
- //
- int $polyLimit = `optionVar -query pfxToPolyLimit`;
- intSliderGrp -edit -v $polyLimit pfxToPolyLimitSlider;
- }
-
- //
- // Procedure Name:
- // paintEffectsToPolyCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc paintEffectsToPolyCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- // Vertex Color Mode
- //
- int $val = `radioButtonGrp -query -select pfxToPolyVertColorMode`;
- optionVar -intValue pfxToPolyVertColorMode ($val-1);
-
- // Quad Output
- //
- optionVar -intValue pfxToPolyQuadOutput
- `checkBoxGrp -q -v1 pfxToPolyQuadOutputBox`;
-
- // Hide Strokes
- //
- optionVar -intValue pfxToPolyHideStrokes
- `checkBoxGrp -q -v1 pfxToPolyHideStrokesBox`;
-
- // Poly Limit
- //
- optionVar -intValue pfxToPolyLimit
- `intSliderGrp -q -v pfxToPolyLimitSlider`;
-
- if ($doIt) {
- performPaintEffectsToPoly 0;
- addToRecentCommandQueue "performPaintEffectsToPoly 0" "PaintEffectsToPoly";
- }
- }
-
- //
- // Procedure Name:
- // paintEffectsToPolyOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc paintEffectsToPolyOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "paintEffectsToPoly";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- setOptionBoxCommandName($commandName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -tabsVisible 0 -scrollable 1;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Vertex Color Mode
- //
- string $radioBtnGrp1 =`radioButtonGrp
- -nrb 3
- -label "Vertex Color Mode"
- -l1 "None"
- -l2 "Color"
- -l3 "Illuminated"
- pfxToPolyVertColorMode`;
-
- checkBoxGrp -label "Quad Output" -l1 ""
- pfxToPolyQuadOutputBox;
-
- checkBoxGrp -label "Hide Strokes" -l1 ""
- pfxToPolyHideStrokesBox;
-
- intSliderGrp
- -label "Poly Limit"
- -field 1
- -min 0
- -max 100000
- -fieldMinValue 0
- -fieldMaxValue 1000000
- -ann "Limit number of faces per output mesh: a value of 0 means no limit."
- pfxToPolyLimitSlider;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit -l "Convert"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("Paint Effects To Polygons Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "PaintEffectsToPoly" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // paintEffectsToPolyHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string paintEffectsToPolyHelp()
- {
- return
- " Command: doPaintEffectsToPoly- tessellate paint effects strokes into polygons.\n" +
- "Selection: Paint Effects strokes.";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- proc string assembleCmd()
- {
- setOptionVars(false);
-
- int $vertColorMode = `optionVar -query pfxToPolyVertColorMode`;
- int $quadOutput = `optionVar -query pfxToPolyQuadOutput`;
- int $hideStrokes = `optionVar -query pfxToPolyHideStrokes`;
- int $polyLimit = `optionVar -query pfxToPolyLimit`;
- int $doHistory = `constructionHistory -q -tgl`;
-
- string $cmd = ("doPaintEffectsToPoly( "
- +$doHistory
- +","+$vertColorMode
- +","+$quadOutput
- +","+$hideStrokes
- +","+$polyLimit+")");
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performPaintEffectsToPoly
- //
- // Description:
- // Perform the performPaintEffectsToPoly command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the performPaintEffectsToPoly command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- global proc string performPaintEffectsToPoly(int $action)
- {
- string $cmd = "";
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- // TODO change this to eval and have doPaintEffectsToPoly call
- // a second routine with evalEcho, so that this command is echoed
- // when returned (case 2 below )
- evalEcho($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- paintEffectsToPolyOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-